/*************************************************************************
	> File Name: P1595.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-09 10:50:29
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

long long f[30];

int main() {
    int n;
    cin >> n;
    f[1] = 0;
    f[2] = 1;
    for (int i = 3; i <= n; i++) {
        f[i] = (i - 1) * (f[i - 2] + f[i - 1]);
    }
    cout << f[n] << endl;
    return 0;
}
